<!DOCTYPE html><html lang="zh-Hans"><head><meta name="generator" content="Hexo 3.8.0"><meta http-equiv="content-type" content="text/html; charset=utf-8"><meta content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=0" name="viewport"><meta content="yes" name="apple-mobile-web-app-capable"><meta content="black-translucent" name="apple-mobile-web-app-status-bar-style"><meta content="telephone=no" name="format-detection"><meta name="description" content="漫漫IT路，持一颗恒心，带一份执着！"><title>菜鸟IT路 | dev-heaven</title><link rel="stylesheet" type="text/css" href="/css/style.css?v=0.0.0"><link rel="stylesheet" type="text/css" href="//lib.baomitu.com/normalize/8.0.1/normalize.min.css"><link rel="stylesheet" type="text/css" href="//lib.baomitu.com/pure/1.0.0/pure-min.css"><link rel="stylesheet" type="text/css" href="//lib.baomitu.com/pure/1.0.0/grids-responsive-min.css"><link rel="stylesheet" href="//lib.baomitu.com/font-awesome/4.7.0/css/font-awesome.min.css"><script type="text/javascript" src="//lib.baomitu.com/jquery/3.4.0/jquery.min.js"></script><link rel="icon" mask sizes="any" href="/favicon.ico"><link rel="Shortcut Icon" type="image/x-icon" href="/favicon.ico"><link rel="apple-touch-icon" href="/apple-touch-icon.png"><link rel="apple-touch-icon-precomposed" href="/apple-touch-icon.png"></head><body><div class="body_container"><div id="header"><div class="site-name"><h1 class="hidden">菜鸟IT路</h1><a id="logo" href="/.">菜鸟IT路</a><p class="description">dev-heaven</p></div><div id="nav-menu"><a class="current" href="/."><i class="fa fa-home">Inicio</i></a><a href="/archives/"><i class="fa fa-archive"> Archivo</i></a><a href="/about/"><i class="fa fa-user"> Acerca de</i></a><a href="/atom.xml"><i class="fa fa-rss"> RSS</i></a></div></div><div class="pure-g" id="layout"><div class="pure-u-1 pure-u-md-3-4"><div class="content_container"><div class="post"><h1 class="post-title"><a href="/posts/45812.html">记一次简单的shell使用</a></h1><div class="post-meta">2017-02-28</div><div class="post-content"><blockquote><p>写了一大堆话还是删了，还是来简单交代下任务背景及需求。<br>昨天上线了一个接收回调并处理订单数据的模块，测试不是特别充分，其中的bug导致部分数据处理不成功，大概100多条，所幸回调的数据被记录在日志里，并且数据库中能够看出哪些订单处理出错，所以现在需要模拟回调。</p></blockquote><p>从日志中grep出数据，然后用curl模拟回调，grep出的数据格式如下：</p><figure class="highlight perl"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="number">2017</span>-<span class="number">02</span>-<span class="number">27</span> <span class="number">11</span>:<span class="number">30</span>:<span class="number">45</span>,<span class="number">609</span> INFO [<span class="number">10.168</span>.<span class="number">89.192</span>:<span class="number">57188</span> http-bio-<span class="number">8080</span>-<span class="keyword">exec</span>-<span class="number">33</span>] com.ins.car.common.aop.WebLogAspect.doAround(WebLogAspect.java:<span class="number">57</span>) - CarOrderController.uniOrder <span class="number">2017</span>-<span class="number">02</span>-<span class="number">27</span> <span class="number">11</span>:<span class="number">30</span>:<span class="number">45</span>,<span class="number">609</span> &#123;<span class="string">"company"</span>:<span class="string">"OFFICIAL"</span>,<span class="string">"request_body"</span>:<span class="string">"jsonData=%7b%22businPrice%22%3a%221774.03%22%2c%22callUrl%22%3a%22http%3a%2f%2f10.40.130.139%2fcallback%22%2c%22carShipTax%22%3a%22360%22%2c%22cooperId%22%3a%2292998109037%22%2c%22customerName%22%3a%22%e5%bc%a0%e9%9b%aa%22%2c%22endDate%22%3a%222018-04-11%22%2c%22insurPrice%22%3a%22665%22%2c%22note%22%3a%22%22%2c%22outTime%22%3a%222017-02-27+11%3a30%3a29.0%22%2c%22payUrl%22%3a%22%22%2c%22no%22%3a%2220173706D000001322%22%2c%22startDate%22%3a%222017-04-12%22%2c%22state%22%3a%22payed%22%2c%22sumPrice%22%3a%222799.03%22%7d"</span>,<span class="string">"query_str"</span>:<span class="string">""</span>,<span class="string">"callback_url"</span>:<span class="string">"http://10.40.130.139/callback"</span>&#125; ============&gt; <span class="number">2017</span>-<span class="number">02</span>-<span class="number">27</span> <span class="number">11</span>:<span class="number">30</span>:<span class="number">45</span>,<span class="number">650</span> &#123;<span class="string">"data"</span>:&#123;<span class="string">"client_channel"</span>:<span class="number">0</span>,<span class="string">"type"</span>:<span class="number">3</span>,<span class="string">"order_id"</span>:<span class="string">"92998109037"</span>&#125;,<span class="string">"return_message"</span>:<span class="string">"[通知]日期格式不正确，请重试！"</span>,<span class="string">"return_code"</span>:-<span class="number">100</span>&#125;</span><br></pre></td></tr></table></figure><p>从数据库中将需要处理的订单的单号取出来导到need_process.txt中，每行一个单号。</p><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#!/bin/bash</span></span><br><span class="line"></span><br><span class="line"><span class="keyword">for</span> order_id <span class="keyword">in</span> `cat need_process.txt`</span><br><span class="line"><span class="keyword">do</span></span><br><span class="line">   content=`grep <span class="variable">$order_id</span> data.log | grep <span class="string">'日期格式不正确'</span> | egrep -o <span class="string">'jsonData[^"]+'</span>`</span><br><span class="line"></span><br><span class="line">   <span class="built_in">echo</span> <span class="string">"<span class="variable">$order_id</span> =====&gt; <span class="variable">$content</span>"</span></span><br><span class="line"></span><br><span class="line">   <span class="keyword">if</span> [ -n <span class="variable">$content</span> ]; <span class="keyword">then</span></span><br><span class="line">      curl -XPOST https://www.abc.com/callback.do -d <span class="string">"<span class="variable">$content</span>"</span></span><br><span class="line">   <span class="keyword">fi</span></span><br><span class="line">   <span class="comment">#echo "$order_id"</span></span><br><span class="line"><span class="keyword">done</span></span><br></pre></td></tr></table></figure><blockquote><p>注意正则的使用。-o 表示只输出匹配正则的数据。</p></blockquote></div><p class="readmore"><a href="/posts/45812.html">Leer más</a></p></div><div class="post"><h1 class="post-title"><a href="/posts/54279.html">SpringBoot with log4j2 - ERROR StatusLogger No log4j2 configuration file found.</a></h1><div class="post-meta">2017-02-23</div><div class="post-content"><blockquote><p>日志的重要性，不言而喻，Spring Boot支持大部分的log配置，其中包括：<br>（1）java util logging<br>（2）log4j<br>（3）log4j2<br>（4）logbak<br>默认的情况下spring boot会选择logback作为日志记录的载体。</p></blockquote><p>我们都知道log配置文件都需要安装固定文件名命名才能被log系统自动加载，比如log4j能够自动加载log4j.properties，log4j2能自动加载log4j2.xml，log4j2-test.xml等命名规则的配置文件。</p><h3 id="问题描述"><a href="#问题描述" class="headerlink" title="问题描述"></a>问题描述</h3><p>关于log4j2，在SpringBoot中，官方推荐使用log4j2-spring.xml命名，系统启动时打印了一句error，虽然不影响运行，但是看着怪怪的，即使在springboot配置文件application.properties中配置了log4j2配置文件 <code>logging.config=classpath:log4j2-spring.xml</code>，但是任然会报如下错误：<br></p><figure class="highlight routeros"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="builtin-name">ERROR</span> StatusLogger <span class="literal">No</span> log4j2 configuration file found. Using<span class="built_in"> default </span>configuration:<span class="built_in"> logging </span>only errors <span class="keyword">to</span> the console.</span><br></pre></td></tr></table></figure><p></p><h3 id="原因"><a href="#原因" class="headerlink" title="原因"></a>原因</h3><p>原因是log4j2不能自动加载log4j2-spring.xml</p><h3 id="解决"><a href="#解决" class="headerlink" title="解决"></a>解决</h3><ol><li>直接忽略官方推荐，以log4j.xml命名</li><li>通过log4j2的插件机制(@Plugin)加载log4j2-spring.xml</li></ol><figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">/*</span></span><br><span class="line"><span class="comment"> * Copyright 2012-2016 the original author or authors.</span></span><br><span class="line"><span class="comment"> *</span></span><br><span class="line"><span class="comment"> * Licensed under the Apache License, Version 2.0 (the "License");</span></span><br><span class="line"><span class="comment"> * you may not use this file except in compliance with the License.</span></span><br><span class="line"><span class="comment"> * You may obtain a copy of the License at</span></span><br><span class="line"><span class="comment"> *</span></span><br><span class="line"><span class="comment"> *      http://www.apache.org/licenses/LICENSE-2.0</span></span><br><span class="line"><span class="comment"> *</span></span><br><span class="line"><span class="comment"> * Unless required by applicable law or agreed to in writing, software</span></span><br><span class="line"><span class="comment"> * distributed under the License is distributed on an "AS IS" BASIS,</span></span><br><span class="line"><span class="comment"> * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.</span></span><br><span class="line"><span class="comment"> * See the License for the specific language governing permissions and</span></span><br><span class="line"><span class="comment"> * limitations under the License.</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"></span><br><span class="line"><span class="keyword">package</span> org.springframework.boot.logging.log4j2;</span><br><span class="line"></span><br><span class="line"><span class="keyword">import</span> java.net.URI;</span><br><span class="line"></span><br><span class="line"><span class="keyword">import</span> org.apache.logging.log4j.core.LoggerContext;</span><br><span class="line"><span class="keyword">import</span> org.apache.logging.log4j.core.config.Configuration;</span><br><span class="line"><span class="keyword">import</span> org.apache.logging.log4j.core.config.ConfigurationFactory;</span><br><span class="line"><span class="keyword">import</span> org.apache.logging.log4j.core.config.ConfigurationSource;</span><br><span class="line"><span class="keyword">import</span> org.apache.logging.log4j.core.config.DefaultConfiguration;</span><br><span class="line"><span class="keyword">import</span> org.apache.logging.log4j.core.config.Order;</span><br><span class="line"><span class="keyword">import</span> org.apache.logging.log4j.core.config.plugins.Plugin;</span><br><span class="line"></span><br><span class="line"><span class="comment">/**</span></span><br><span class="line"><span class="comment"> * Spring Boot &#123;<span class="doctag">@link</span> ConfigurationFactory&#125; that prevents logger warnings from being</span></span><br><span class="line"><span class="comment"> * printed when the application first starts.</span></span><br><span class="line"><span class="comment"> *</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@author</span> Phillip Webb</span></span><br><span class="line"><span class="comment"> * <span class="doctag">@since</span> 1.5.0</span></span><br><span class="line"><span class="comment"> */</span></span><br><span class="line"><span class="meta">@Plugin</span>(name = <span class="string">"SpringBootConfigurationFactory"</span>, category = ConfigurationFactory.CATEGORY)</span><br><span class="line"><span class="meta">@Order</span>(<span class="number">4</span>) <span class="comment">// Order behind XmlConfigurationFactory</span></span><br><span class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">SpringBootConfigurationFactory</span> <span class="keyword">extends</span> <span class="title">ConfigurationFactory</span> </span>&#123;</span><br><span class="line"></span><br><span class="line">	<span class="keyword">private</span> <span class="keyword">static</span> <span class="keyword">final</span> String[] ALL_TYPES = &#123; <span class="string">"*"</span> &#125;;</span><br><span class="line"></span><br><span class="line">	<span class="meta">@Override</span></span><br><span class="line">	<span class="keyword">protected</span> String[] getSupportedTypes() &#123;</span><br><span class="line">		<span class="keyword">return</span> ALL_TYPES;</span><br><span class="line">	&#125;</span><br><span class="line"></span><br><span class="line">	<span class="meta">@Override</span></span><br><span class="line">	<span class="function"><span class="keyword">public</span> Configuration <span class="title">getConfiguration</span><span class="params">(LoggerContext loggerContext, String name,</span></span></span><br><span class="line"><span class="function"><span class="params">			URI configLocation)</span> </span>&#123;</span><br><span class="line">		<span class="keyword">if</span> (configLocation == <span class="keyword">null</span>) &#123;</span><br><span class="line">			<span class="keyword">return</span> <span class="keyword">new</span> DefaultConfiguration();</span><br><span class="line">		&#125;</span><br><span class="line">		<span class="keyword">return</span> <span class="keyword">null</span>;</span><br><span class="line">	&#125;</span><br><span class="line"></span><br><span class="line">	<span class="meta">@Override</span></span><br><span class="line">	<span class="function"><span class="keyword">public</span> Configuration <span class="title">getConfiguration</span><span class="params">(LoggerContext loggerContext, String name,</span></span></span><br><span class="line"><span class="function"><span class="params">			URI configLocation, ClassLoader loader)</span> </span>&#123;</span><br><span class="line">		<span class="keyword">return</span> <span class="keyword">null</span>;</span><br><span class="line">	&#125;</span><br><span class="line"></span><br><span class="line">	<span class="meta">@Override</span></span><br><span class="line">	<span class="function"><span class="keyword">public</span> Configuration <span class="title">getConfiguration</span><span class="params">(LoggerContext loggerContext,</span></span></span><br><span class="line"><span class="function"><span class="params">			ConfigurationSource source)</span> </span>&#123;</span><br><span class="line">		<span class="keyword">return</span> <span class="keyword">null</span>;</span><br><span class="line">	&#125;</span><br><span class="line"></span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure><p>上述插件取自：<a href="https://github.com/spring-projects/spring-boot/commit/1e9e1b04d00ec319e0473f8126b39e6b72ef1de8#diff-c5a5f1786a9591c088e86c4e388939caR34" target="_blank" rel="noopener">https://github.com/spring-projects/spring-boot/commit/1e9e1b04d00ec319e0473f8126b39e6b72ef1de8#diff-c5a5f1786a9591c088e86c4e388939caR34</a></p><p>可以看到@since 1.5.0 ，所以如果将SpringBoot升级到1.5.0，就可以解决这个问题，或者将这个plugin放到自己的系统中。</p></div><p class="readmore"><a href="/posts/54279.html">Leer más</a></p></div><div class="post"><h1 class="post-title"><a href="/posts/62789.html">css之清除浮动</a></h1><div class="post-meta">2017-02-11</div><div class="post-content"><blockquote><p>此文章和上篇文章<a href="https://dev-heaven.com/2017/02/07/css%E5%B7%A6%E5%8F%B3%E5%B8%83%E5%B1%80/" target="_blank" rel="noopener">css左右布局</a>有相同之处，只是文章侧重点不同。<br>在两栏布局中，如果有页脚的话，如果不清除浮动，会导致页面主体部分搞定塌陷，这就需要清除浮动！</p></blockquote><p>看下面的HTML代码，结构一目了然，container包含menu和main，最底部是footer，为了使menu和main位于一行，需要同时左浮动（float: left;），此时会出现高度塌陷，如图。</p><p><img src="https://static.dev-heaven.com/images/QQ20170211-0@2x.png" alt="未清除浮动的时候高度塌陷"></p><p>可以看到截图最上部有一条宽度为2px的线，其实它是container容器的边框，也就是本应该包含left和main的container高度为0，这就是所谓的高度塌陷。</p><figure class="highlight html"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">&lt;!DOCTYPE html&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">html</span> <span class="attr">lang</span>=<span class="string">"en"</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">head</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">meta</span> <span class="attr">charset</span>=<span class="string">"UTF-8"</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">title</span>&gt;</span>float<span class="tag">&lt;/<span class="name">title</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">style</span>&gt;</span><span class="undefined"></span></span><br><span class="line"><span class="xml">    <span class="comment">&lt;!-- 用于区分各个div之间的关系 --&gt;</span></span></span><br><span class="line"><span class="css">    <span class="selector-class">.container</span>,</span></span><br><span class="line"><span class="css">    <span class="selector-class">.menu</span>,</span></span><br><span class="line"><span class="css">    <span class="selector-class">.main</span>,</span></span><br><span class="line"><span class="css">    <span class="selector-class">.footer</span> &#123;</span></span><br><span class="line"><span class="css">        <span class="selector-tag">border</span>: 1<span class="selector-tag">px</span> <span class="selector-tag">solid</span> <span class="selector-id">#000</span>;</span></span><br><span class="line"><span class="undefined">    &#125;</span></span><br><span class="line"><span class="css">    <span class="selector-class">.menu</span> &#123;</span></span><br><span class="line"><span class="undefined">        background-color: green;</span></span><br><span class="line"><span class="undefined">    &#125;</span></span><br><span class="line"><span class="undefined">    </span></span><br><span class="line"><span class="css">    <span class="selector-class">.main</span> &#123;</span></span><br><span class="line"><span class="undefined">        background-color: red;</span></span><br><span class="line"><span class="undefined">    &#125;</span></span><br><span class="line"><span class="css">    <span class="selector-class">.footer</span> &#123;</span></span><br><span class="line"><span class="undefined">        margin-top: 10px;</span></span><br><span class="line"><span class="undefined">    &#125;</span></span><br><span class="line"><span class="undefined"></span></span><br><span class="line"><span class="undefined">   	&lt;!-- </span></span><br><span class="line"><span class="undefined">   		让menu和main同时浮动，居于同一排 </span></span><br><span class="line"><span class="undefined">   	--&gt;</span></span><br><span class="line"><span class="css">    <span class="selector-class">.menu</span>,</span></span><br><span class="line"><span class="css">    <span class="selector-class">.main</span> &#123;</span></span><br><span class="line"><span class="undefined">        float: left;</span></span><br><span class="line"><span class="undefined">        margin: 10px;</span></span><br><span class="line"><span class="undefined">        width: 48%;</span></span><br><span class="line"><span class="undefined">        height: 200px;</span></span><br><span class="line"><span class="undefined">    &#125;</span></span><br><span class="line"><span class="undefined">    </span><span class="tag">&lt;/<span class="name">style</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">head</span>&gt;</span></span><br><span class="line"></span><br><span class="line"><span class="tag">&lt;<span class="name">body</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">div</span> <span class="attr">class</span>=<span class="string">"container"</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">div</span> <span class="attr">class</span>=<span class="string">"menu"</span>&gt;</span></span><br><span class="line">            我是菜单部分</span><br><span class="line">        <span class="tag">&lt;/<span class="name">div</span>&gt;</span></span><br><span class="line">        <span class="tag">&lt;<span class="name">div</span> <span class="attr">class</span>=<span class="string">"main"</span>&gt;</span></span><br><span class="line">            我是主体内容</span><br><span class="line">        <span class="tag">&lt;/<span class="name">div</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;/<span class="name">div</span>&gt;</span></span><br><span class="line">    <span class="tag">&lt;<span class="name">div</span> <span class="attr">class</span>=<span class="string">"footer"</span>&gt;</span></span><br><span class="line">        我是页脚</span><br><span class="line">    <span class="tag">&lt;/<span class="name">div</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">body</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;/<span class="name">html</span>&gt;</span></span><br></pre></td></tr></table></figure><p>下面我们来清除浮动，css代码如下，在container的div上再加上clearfix这个class就可以了。</p><figure class="highlight css"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line"><span class="selector-class">.clearfix</span><span class="selector-pseudo">:after</span> &#123;</span><br><span class="line">        <span class="attribute">content</span>: <span class="string">"."</span>;</span><br><span class="line">        <span class="attribute">display</span>: block;</span><br><span class="line">        <span class="attribute">height</span>: <span class="number">0</span>;</span><br><span class="line">        <span class="attribute">clear</span>: both;</span><br><span class="line">    &#125;</span><br><span class="line">    </span><br><span class="line">    <span class="selector-class">.clearfix</span> &#123;</span><br><span class="line">        *zoom: 1;</span><br><span class="line">    &#125;</span><br></pre></td></tr></table></figure><p>清除浮动后则正常，如图。</p><p><img src="https://static.dev-heaven.com/images/QQ20170211-1@2x.png" alt></p><p>参考文章：</p><ol><li><a href="http://www.daqianduan.com/3606.html" target="_blank" rel="noopener">http://www.daqianduan.com/3606.html</a></li><li><a href="http://www.iyunlu.com/view/css-xhtml/55.html" target="_blank" rel="noopener">http://www.iyunlu.com/view/css-xhtml/55.html</a></li></ol></div><p class="readmore"><a href="/posts/62789.html">Leer más</a></p></div><div class="post"><h1 class="post-title"><a href="/posts/25096.html">css左右布局</a></h1><div class="post-meta">2017-02-07</div><div class="post-content"><blockquote><p>在后台管理系统中最常见的布局就是左右布局，左侧是菜单，宽度固定，右侧是主体内容，宽度自适应（占据剩余宽度），下面是一个简单的页面布局代码，记录学习！</p></blockquote></div><p class="readmore"><a href="/posts/25096.html">Leer más</a></p></div><div class="post"><h1 class="post-title"><a href="/posts/9488.html">Express上传文件</a></h1><div class="post-meta">2017-01-18</div><div class="post-content"><blockquote><p>废话少说，直接上代码！</p></blockquote><h3 id="引入依赖"><a href="#引入依赖" class="headerlink" title="引入依赖"></a>引入依赖</h3><figure class="highlight stylus"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">npm <span class="selector-tag">i</span> connect-multiparty --save</span><br></pre></td></tr></table></figure><h3 id="上传代码"><a href="#上传代码" class="headerlink" title="上传代码"></a>上传代码</h3><figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">var</span> express = <span class="built_in">require</span>(<span class="string">'express'</span>);</span><br><span class="line"><span class="keyword">var</span> router = express.Router();</span><br><span class="line"></span><br><span class="line"><span class="keyword">var</span> multipart = <span class="built_in">require</span>(<span class="string">'connect-multiparty'</span>);</span><br><span class="line"><span class="keyword">var</span> multipartMiddleware = multipart();</span><br><span class="line"><span class="keyword">var</span> fs = <span class="built_in">require</span>(<span class="string">'fs'</span>);</span><br><span class="line"><span class="keyword">var</span> path = <span class="built_in">require</span>(<span class="string">'path'</span>);</span><br><span class="line"></span><br><span class="line">router.post(<span class="string">'/upload'</span>, multipartMiddleware, <span class="function"><span class="keyword">function</span> (<span class="params">req, res, next</span>) </span>&#123;</span><br><span class="line">    <span class="keyword">var</span> dst = path.join(__dirname, <span class="string">'../public'</span>, <span class="string">'images'</span>, req.files.file.originalFilename);</span><br><span class="line">    fs.rename(req.files.file.path, dst, <span class="function"><span class="keyword">function</span> (<span class="params">err</span>) </span>&#123;</span><br><span class="line">        <span class="keyword">if</span> (err) &#123;</span><br><span class="line">            res.status(<span class="number">500</span>).send(err);</span><br><span class="line">        &#125; <span class="keyword">else</span> &#123;</span><br><span class="line">            res.status(<span class="number">200</span>).send(<span class="string">'uploaded'</span>);</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;);</span><br><span class="line">&#125;);</span><br></pre></td></tr></table></figure><h3 id="关于更多中间件"><a href="#关于更多中间件" class="headerlink" title="关于更多中间件"></a>关于更多中间件</h3><blockquote><p>更多中间件，可以在 <a href="https://www.npmjs.com/" target="_blank" rel="noopener">https://www.npmjs.com/</a>上查找</p></blockquote><p><img src="https://static.dev-heaven.com/images/WX20170118-094021@2x.png" alt></p><p>下面推荐几个和Express上传相关的中间件</p><ul><li><a href="https://www.npmjs.com/package/fileupload" target="_blank" rel="noopener">fileupload</a></li><li><a href="https://www.npmjs.com/package/express-fileupload" target="_blank" rel="noopener">express-fileupload</a></li></ul><h3 id="补充"><a href="#补充" class="headerlink" title="补充"></a>补充</h3><p>在不断学习过程中，发现了一款更加牛掰的中间件<em><a href="https://www.npmjs.com/package/express-fileuploader" target="_blank" rel="noopener">express-fileuploader</a></em></p><h4 id="功能"><a href="#功能" class="headerlink" title="功能"></a>功能</h4><ul><li><a href="https://github.com/heroicyang/express-fileuploader" target="_blank" rel="noopener">服务器</a></li><li><a href="https://github.com/heroicyang/express-fileuploader-qiniu" target="_blank" rel="noopener">七牛</a></li><li><a href="https://github.com/heroicyang/express-fileuploader-oss" target="_blank" rel="noopener">阿里云OSS</a></li></ul></div><p class="readmore"><a href="/posts/9488.html">Leer más</a></p></div><div class="post"><h1 class="post-title"><a href="/posts/47717.html">nrm—npm数据源管理工具</a></h1><div class="post-meta">2017-01-11</div><div class="post-content"><blockquote><p>nrm 是一个管理 npm 源的工具。用过 ruby 和 gem 的同学会比较熟悉，通常我们会把 gem 源切到国内的淘宝镜像，这样在安装和更新一些包的时候比较快。nrm 同理，用来切换官方 npm 源和国内的 npm 源（如: cnpm），当然也可以用来切换官方 npm 源和公司私有 npm 源。</p></blockquote><p>全局安装 nrm:</p><figure class="highlight stylus"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">npm <span class="selector-tag">i</span> nrm -g</span><br></pre></td></tr></table></figure><p>查看当前 nrm 内置的几个 npm 源的地址：</p><p><img src="https://static.dev-heaven.com/images/nrm-ls.png" alt></p><p>切换到 cnpm：</p><p><img src="https://static.dev-heaven.com/images/nrm-use.png" alt></p></div><p class="readmore"><a href="/posts/47717.html">Leer más</a></p></div><div class="post"><h1 class="post-title"><a href="/posts/35412.html">cpu 98%之谜-wnTKYg</a></h1><div class="post-meta">2017-01-07</div><div class="post-content"><blockquote><p>晚上想把前段时间（几个月了……）部署的Jenkins重启下，发现Tomcat启动极慢，没事，我等呗，我已开始以为Jenkins在启动的时候会做些更新，所以才导致慢，实际上真的做了下载</p><figure class="highlight stylus"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><span class="line">&gt; 四月 <span class="number">07</span>, <span class="number">2017</span> <span class="number">9</span>:<span class="number">29</span>:<span class="number">20</span> 下午 hudson.WebAppMain$<span class="number">3</span> run</span><br><span class="line">信息: Jenkins is fully up and running</span><br><span class="line">四月 <span class="number">07</span>, <span class="number">2017</span> <span class="number">9</span>:<span class="number">29</span>:<span class="number">22</span> 下午 hudson<span class="selector-class">.model</span><span class="selector-class">.UpdateSite</span> updateData</span><br><span class="line">信息: Obtained the latest update center data file <span class="keyword">for</span> UpdateSource default</span><br><span class="line">四月 <span class="number">07</span>, <span class="number">2017</span> <span class="number">9</span>:<span class="number">29</span>:<span class="number">23</span> 下午 hudson<span class="selector-class">.model</span><span class="selector-class">.DownloadService</span><span class="variable">$Downloadable</span> load</span><br><span class="line">信息: Obtained the updated data file <span class="keyword">for</span> hudson<span class="selector-class">.tasks</span><span class="selector-class">.Maven</span><span class="selector-class">.MavenInstaller</span></span><br><span class="line">四月 <span class="number">07</span>, <span class="number">2017</span> <span class="number">9</span>:<span class="number">29</span>:<span class="number">25</span> 下午 hudson<span class="selector-class">.model</span><span class="selector-class">.DownloadService</span><span class="variable">$Downloadable</span> load</span><br><span class="line">信息: Obtained the updated data file <span class="keyword">for</span> hudson<span class="selector-class">.tasks</span><span class="selector-class">.Ant</span><span class="selector-class">.AntInstaller</span></span><br><span class="line">四月 <span class="number">07</span>, <span class="number">2017</span> <span class="number">9</span>:<span class="number">29</span>:<span class="number">26</span> 下午 hudson<span class="selector-class">.model</span><span class="selector-class">.DownloadService</span><span class="variable">$Downloadable</span> load</span><br><span class="line">信息: Obtained the updated data file <span class="keyword">for</span> hudson<span class="selector-class">.plugins</span><span class="selector-class">.gradle</span><span class="selector-class">.GradleInstaller</span></span><br><span class="line">四月 <span class="number">07</span>, <span class="number">2017</span> <span class="number">9</span>:<span class="number">30</span>:<span class="number">19</span> 下午 hudson<span class="selector-class">.model</span><span class="selector-class">.DownloadService</span><span class="variable">$Downloadable</span> load</span><br><span class="line">信息: Obtained the updated data file <span class="keyword">for</span> hudson<span class="selector-class">.tools</span><span class="selector-class">.JDKInstaller</span></span><br><span class="line">四月 <span class="number">07</span>, <span class="number">2017</span> <span class="number">9</span>:<span class="number">30</span>:<span class="number">19</span> 下午 hudson<span class="selector-class">.model</span><span class="selector-class">.AsyncPeriodicWork</span>$<span class="number">1</span> run</span><br><span class="line">信息: Finished Download metadata. <span class="number">106</span>,<span class="number">725</span> ms</span><br><span class="line">&gt;</span><br></pre></td></tr></table></figure><p>但是也不至于这么慢啊，查看了下CPU 98.9%，这还得了？！</p></blockquote><h4 id="看现象"><a href="#看现象" class="headerlink" title="看现象"></a>看现象</h4><figure class="highlight tap"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br></pre></td><td class="code"><pre><span class="line">top - 21:28:56 up<span class="number"> 170 </span>days, 22:20, <span class="number"> 1 </span>user,  load average: 4.08, 3.31, 2.31</span><br><span class="line">Tasks:<span class="number"> 113 </span>total,  <span class="number"> 2 </span>running,<span class="number"> 110 </span>sleeping,  <span class="number"> 0 </span>stopped,  <span class="number"> 1 </span>zombie</span><br><span class="line">%Cpu(s): 99.3 us,  0.7 sy,  0.0 ni,  0.0 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st</span><br><span class="line">KiB Mem : <span class="number"> 1882680 </span>total,   <span class="number"> 72168 </span>free,  <span class="number"> 963532 </span>used,  <span class="number"> 846980 </span>buff/cache</span><br><span class="line">KiB Swap:       <span class="number"> 0 </span>total,       <span class="number"> 0 </span>free,       <span class="number"> 0 </span>used.  <span class="number"> 613516 </span>avail Mem </span><br><span class="line"></span><br><span class="line">  PID USER      PR  NI    VIRT    RES    SHR S %CPU %MEM     TIME+ COMMAND                                                                                                 </span><br><span class="line">30498 root     <span class="number"> 20 </span> <span class="number"> 0 </span><span class="number"> 223048 </span> <span class="number"> 4540 </span>  <span class="number"> 428 </span>S 89.1  0.2  36829:41 wnTKYg                                                                                                  </span><br><span class="line">23331 root     <span class="number"> 20 </span> <span class="number"> 0 </span>2576908<span class="number"> 329956 </span><span class="number"> 23360 </span>S  8.9 17.5   0:41.60 java                                                                                                    </span><br><span class="line">  <span class="number"> 24 </span>root     <span class="number"> 20 </span> <span class="number"> 0 </span>     <span class="number"> 0 </span>    <span class="number"> 0 </span>    <span class="number"> 0 </span>S  0.3  0.0  79:06.15 rcu_sched                                                                                               </span><br><span class="line">23422 root     <span class="number"> 20 </span> <span class="number"> 0 </span><span class="number"> 157716 </span> <span class="number"> 2212 </span> <span class="number"> 1532 </span>R  0.3  0.1   0:00.69 top                                                                                                     </span><br><span class="line">31823 root     <span class="number"> 20 </span> <span class="number"> 0 </span><span class="number"> 243240 </span><span class="number"> 38400 </span> <span class="number"> 2408 </span>S  0.3  2.0 223:02.23 AliHids                                                                                                 </span><br><span class="line">   <span class="number"> 1 </span>root     <span class="number"> 20 </span> <span class="number"> 0 </span><span class="number"> 190704 </span> <span class="number"> 3244 </span> <span class="number"> 1976 </span>S  0.0  0.2   4:42.32 systemd                                                                                                 </span><br><span class="line">   <span class="number"> 2 </span>root     <span class="number"> 20 </span> <span class="number"> 0 </span>     <span class="number"> 0 </span>    <span class="number"> 0 </span>    <span class="number"> 0 </span>S  0.0  0.0   0:00.16 kthreadd                                                                                                </span><br><span class="line">   <span class="number"> 3 </span>root     <span class="number"> 20 </span> <span class="number"> 0 </span>     <span class="number"> 0 </span>    <span class="number"> 0 </span>    <span class="number"> 0 </span>S  0.0  0.0   0:22.99 ksoftirqd/0                                                                                             </span><br><span class="line">   <span class="number"> 5 </span>root      <span class="number"> 0 </span>-20      <span class="number"> 0 </span>    <span class="number"> 0 </span>    <span class="number"> 0 </span>S  0.0  0.0   0:00.00 kworker/0:0H                                                                                            </span><br><span class="line">   <span class="number"> 7 </span>root      rt  <span class="number"> 0 </span>     <span class="number"> 0 </span>    <span class="number"> 0 </span>    <span class="number"> 0 </span>S  0.0  0.0   0:00.00 migration/0                                                                                             </span><br><span class="line">   <span class="number"> 8 </span>root     <span class="number"> 20 </span> <span class="number"> 0 </span>     <span class="number"> 0 </span>    <span class="number"> 0 </span>    <span class="number"> 0 </span>S  0.0  0.0   0:00.00 rcu_bh                                                                                                  </span><br><span class="line">   <span class="number"> 9 </span>root     <span class="number"> 20 </span> <span class="number"> 0 </span>     <span class="number"> 0 </span>    <span class="number"> 0 </span>    <span class="number"> 0 </span>S  0.0  0.0   0:00.00 rcuob/0                                                                                                 </span><br><span class="line">  <span class="number"> 10 </span>root     <span class="number"> 20 </span> <span class="number"> 0 </span>     <span class="number"> 0 </span>    <span class="number"> 0 </span>    <span class="number"> 0 </span>S  0.0  0.0   0:00.00 rcuob/1</span><br></pre></td></tr></table></figure><p>一个叫wnTKYg的程序占了89%+，不管三七二十一，它必须死！<code>pkill wnTKYg</code></p><h4 id="查原因"><a href="#查原因" class="headerlink" title="查原因"></a>查原因</h4><p>查下这个 wnTKYg吧，搜索结果如下 <a href="http://rdc.hundsun.com/portal/article/681.html?from=CSDN" target="_blank" rel="noopener">http://rdc.hundsun.com/portal/article/681.html?from=CSDN</a></p><p><code>wnTKYg同minerd和AnXqV两个一样都是挖矿程序, 应该是利用 redis 漏洞入侵，加了定时任务，每一段时间向固定地址发送请求，执行挖矿程序后导致 cpu 和带宽 100%， kill 进程会自动重启。</code></p><h4 id="教训"><a href="#教训" class="headerlink" title="教训"></a>教训</h4><p>吃一堑长一智，上次mongodb被攻击，阿里云ESC被入侵，到这次redis被攻击，学到了很多东西</p><h5 id="一、安全很重要"><a href="#一、安全很重要" class="headerlink" title="一、安全很重要"></a>一、安全很重要</h5><p>别以为你弄个服务器随便部署点自己喜欢的东西，黑客就找不到你，照样攻击你，就算不是为了利益，人家一样在玩，或者他是初级黑客，专门攻击你这种小菜鸟。</p><h5 id="二、没事还是把防火墙开起来吧"><a href="#二、没事还是把防火墙开起来吧" class="headerlink" title="二、没事还是把防火墙开起来吧"></a>二、没事还是把防火墙开起来吧</h5><h5 id="三、禁止密码登录服务器"><a href="#三、禁止密码登录服务器" class="headerlink" title="三、禁止密码登录服务器"></a>三、禁止密码登录服务器</h5><h5 id="四、最好还是弄个端口转发到服务器"><a href="#四、最好还是弄个端口转发到服务器" class="headerlink" title="四、最好还是弄个端口转发到服务器"></a>四、最好还是弄个端口转发到服务器</h5></div><p class="readmore"><a href="/posts/35412.html">Leer más</a></p></div><div class="post"><h1 class="post-title"><a href="/posts/54876.html">我是如何给我的个人网站升级https的</a></h1><div class="post-meta">2016-12-28</div><div class="post-content"><blockquote><p>2016就要过去了，回来的时候在公交上直接睡着了，差点坐过站，2016有很多无奈，希望2017一切尽如人意，做自己喜欢的事情，再苦再累也愿意！有点跑题，还是说说昨天做的事情吧，烂笔头一直在路上。</p><p>随着2016年的结束，HTTPS的时代就要来了，苹果在今年的全球开发者大会上通告自2017-01-01开始，上架AppStore的应用必须使用HTTPS，Google也做出自2017开始，chrome将对未使用HTTPS的网站标注为不安全。所以，还是来做做HTTPS吧。</p></blockquote><h3 id="选择"><a href="#选择" class="headerlink" title="选择"></a>选择</h3><p>全球有很多CA机构提供证书服务，我们的选择也很多，但是对于我而言，选择还是有限的，因为最好能节约点吧，也没有必要在这方便花费太多在个人博客上。于是我首先选择的<a href="https://startssl.com" target="_blank" rel="noopener">StartCom</a>，其提供的免费一年的证书正好适合我的需求。</p><h4 id="StartCom"><a href="#StartCom" class="headerlink" title="StartCom"></a><a href="https://startssl.com" target="_blank" rel="noopener">StartCom</a></h4><blockquote><p>需要翻墙</p></blockquote><p>虽然网上有很多关于申请StartCom证书流程的说明，但是似乎其网站做过改版，我觉得有必要再重新说一说。</p><h5 id="注册"><a href="#注册" class="headerlink" title="注册"></a>注册</h5><ol><li><p>填写邮箱注册<br><img src="https://static.dev-heaven.com/images/startssl%E6%B3%A8%E5%86%8C.png" alt></p></li><li><p>注册后续步骤<br>在此步骤中，主要是安装用于登录的证书。<br><img src="https://static.dev-heaven.com/images/startssl%E6%B3%A8%E5%86%8C2.png" alt><br>如何安装登录证书？Mac上直接双击即可，Windows自己试试呗！<br>你也可以直接“click ‘here’”进行登录，此时startssl会将一次性密码发到你的邮箱。</p></li></ol><h5 id="申请证书"><a href="#申请证书" class="headerlink" title="申请证书"></a>申请证书</h5><h6 id="域名校验（Domain-Validations）"><a href="#域名校验（Domain-Validations）" class="headerlink" title="域名校验（Domain Validations）"></a>域名校验（Domain Validations）</h6><blockquote><p>也就是校验这个域名到底是不是你的</p></blockquote><ol><li>选择Validations Wizard<br><img src="https://static.dev-heaven.com/images/startssl%E7%94%B3%E8%AF%B7%E8%AF%81%E4%B9%A61.png" alt></li><li>Domain Validations<br><img src="https://static.dev-heaven.com/images/startssl%E8%AF%81%E4%B9%A6%E7%94%B3%E8%AF%B72.png" alt></li><li>选择你的域名邮箱，阿里云的是 postmaster@yourdomain.com<br><img src="https://static.dev-heaven.com/images/startssl%E8%AF%81%E4%B9%A6%E7%94%B3%E8%AF%B73.png" alt></li><li>验证结束<br><img src="https://static.dev-heaven.com/images/startssl%E8%AF%81%E4%B9%A6%E7%94%B3%E8%AF%B74.png" alt></li></ol><h6 id="生成证书"><a href="#生成证书" class="headerlink" title="生成证书"></a>生成证书</h6><ol><li>选择Certificates Wizard，点击DV SSL Certificate<br><img src="https://static.dev-heaven.com/images/startssl%E8%AF%81%E4%B9%A6%E7%94%B3%E8%AF%B75.png" alt><br>进入如下页面：<br><img src="https://static.dev-heaven.com/images/startssl%E8%AF%81%E4%B9%A6%E7%94%B3%E8%AF%B76.png" alt></li><li><p>在服务器上生成csr文件，IE用户请略过2、3步<br>登入服务器，执行：</p><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">openssl req -newkey rsa:2048 -keyout your_file_name.key -out your_file_name.csr</span><br></pre></td></tr></table></figure><p><img src="https://static.dev-heaven.com/images/startssl%E8%AF%81%E4%B9%A6%E7%94%B3%E8%AF%B77.png" alt></p></li><li><p>填入csr<br><img src="https://static.dev-heaven.com/images/startssl%E8%AF%81%E4%B9%A6%E7%94%B3%E8%AF%B78.png" alt></p></li><li>下载证书，点击’here‘<br><img src="https://static.dev-heaven.com/images/startssl%E8%AF%81%E4%B9%A6%E7%94%B3%E8%AF%B79.png" alt></li></ol><h4 id="腾讯云"><a href="#腾讯云" class="headerlink" title="腾讯云"></a><a href="https://www.qcloud.com/product/ssl" target="_blank" rel="noopener">腾讯云</a></h4><p>注册登录腾讯云后，进入控制台，选择云产品 -&gt; SSL证书管理，如图：</p><p><img src="https://static.dev-heaven.com/images/WX20170109-131930@2x.png" alt></p><p>点击申请证书，如图：</p><p><img src="https://static.dev-heaven.com/images/WX20170109-131447@2x.png" alt></p><p>可以看到该证书有TrustAsia(亚洲诚信)机构颁发，唯一不足的是，该证书只支持单个非顶级域名，比如：www.dev-heaven.com，pyenv.dev-heaven.com等。</p><h4 id="比较"><a href="#比较" class="headerlink" title="比较"></a>比较</h4><p>两种证书各有优点，startssl支持多域名，腾讯云证书只支持单个非顶级域名，而腾讯云证书申请简便，startssl相对麻烦。但是有一个startssl有个致命缺点，就是chrome封杀了免费版的startssl证书。</p><h3 id="部署"><a href="#部署" class="headerlink" title="部署"></a>部署</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="built_in">cd</span> /etc/pki/nginx/</span><br><span class="line"><span class="comment">#没有的目录直接mkdir</span></span><br></pre></td></tr></table></figure><h4 id="startssl证书"><a href="#startssl证书" class="headerlink" title="startssl证书"></a>startssl证书</h4><p>文件目录结构</p><figure class="highlight 1c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="string">|- ApacheServer.zip</span></span><br><span class="line"><span class="string">|- IISServer.zip</span></span><br><span class="line"><span class="string">|- NginxServer.zip</span></span><br><span class="line"><span class="string">|- OtherServer.zip</span></span><br></pre></td></tr></table></figure><p>根据你的服务器选择所需的文件，我这里配置的是Nginx。解压NginxServer.zip，将其中的文件和‘生成证书’步骤中生成的your_file_name.key同时上传到服务器的 /etc/pki/nginx/目录下</p><h4 id="腾讯云证书"><a href="#腾讯云证书" class="headerlink" title="腾讯云证书"></a>腾讯云证书</h4><p>文件目录结构</p><figure class="highlight 1c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="string">|- Apache</span></span><br><span class="line"><span class="string">|- IIS</span></span><br><span class="line"><span class="string">|- Nginx</span></span><br><span class="line">	<span class="string">|- 1_www.dev-heaven.com_bundle.crt</span></span><br><span class="line">	<span class="string">|- 2_www.dev-heaven.com.key</span></span><br></pre></td></tr></table></figure><h4 id="配置Nginx"><a href="#配置Nginx" class="headerlink" title="配置Nginx"></a>配置Nginx</h4><blockquote><p>我的nginx version: nginx/1.10.2，其他版本的请自行配置。</p></blockquote><p>在Nginx主配置nginx.conf文件中，将以下内容的注释去掉</p><figure class="highlight nginx"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br></pre></td><td class="code"><pre><span class="line"><span class="section">server</span> &#123;</span><br><span class="line">    <span class="attribute">listen</span>       <span class="number">443</span> ssl http2 default_server;</span><br><span class="line">    <span class="attribute">listen</span>       [::]:<span class="number">443</span> ssl http2 default_server;</span><br><span class="line">    <span class="attribute">server_name</span>  _;</span><br><span class="line">    <span class="attribute">root</span>         /usr/share/nginx/html;</span><br><span class="line"></span><br><span class="line">    <span class="attribute">ssl_certificate</span> <span class="string">"/etc/pki/nginx/1_www.dev-heaven.com_bundle.crt"</span>;</span><br><span class="line">    <span class="attribute">ssl_certificate_key</span> <span class="string">"/etc/pki/nginx/2_www.dev-heaven.com.key"</span>;</span><br><span class="line">    <span class="attribute">ssl_session_cache</span> shared:SSL:<span class="number">1m</span>;</span><br><span class="line">    <span class="attribute">ssl_session_timeout</span>  <span class="number">10m</span>;</span><br><span class="line">    <span class="attribute">ssl_ciphers</span> HIGH:!aNULL:!MD5;</span><br><span class="line">    <span class="attribute">ssl_prefer_server_ciphers</span> <span class="literal">on</span>;</span><br><span class="line"></span><br><span class="line">    <span class="comment"># Load configuration files for the default server block.</span></span><br><span class="line">    <span class="attribute">include</span> /etc/nginx/default.d/<span class="regexp">*.conf</span>;</span><br><span class="line"></span><br><span class="line">    <span class="attribute">location</span> / &#123;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="attribute">error_page</span> <span class="number">404</span> /<span class="number">404</span>.html;</span><br><span class="line">        <span class="attribute">location</span> = /40x.html &#123;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="attribute">error_page</span> <span class="number">500</span> <span class="number">502</span> <span class="number">503</span> <span class="number">504</span> /50x.html;</span><br><span class="line">        <span class="attribute">location</span> = /50x.html &#123;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure><p>将ssl_certificate 和 ssl_certificate_key替换成你自己的key和crt文件。重启Nginx即可，注意是重启，而不是 <code>nginx -s reload</code></p><p>在子配置文件中，比如我的是 dev-heaven.conf</p><figure class="highlight nginx"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br></pre></td><td class="code"><pre><span class="line"><span class="section">server</span> &#123;</span><br><span class="line">    <span class="attribute">listen</span>      <span class="number">443</span>;</span><br><span class="line">    <span class="attribute">server_name</span> www.dev-heaven.com dev-heaven.com;</span><br><span class="line">    <span class="attribute">root</span>        /home/dev/www-data/blog;</span><br><span class="line"></span><br><span class="line">    <span class="attribute">location</span> / &#123;</span><br><span class="line">        <span class="attribute">index</span>   index.html;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="attribute">location</span> <span class="regexp">~* \.(gif|jpg|png)$</span> &#123;</span><br><span class="line">        <span class="attribute">expires</span> <span class="number">30d</span>;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="section">server</span> &#123;</span><br><span class="line">    <span class="attribute">listen</span>      <span class="number">80</span>;</span><br><span class="line">    <span class="attribute">server_name</span> www.dev-heaven.com dev-heaven.com;</span><br><span class="line">    <span class="comment"># 将http访问自动跳转到https</span></span><br><span class="line">    <span class="attribute">rewrite</span> <span class="regexp"> ^/(.*)$</span> https://www.dev-heaven.com/<span class="variable">$1</span> <span class="literal">permanent</span>; </span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure><p>至此，HTTPS升级基本完成了，有问题可以发邮件给我：jarvan4dev@163.com</p><h3 id="补充"><a href="#补充" class="headerlink" title="补充"></a>补充</h3><p>由于使用了七牛云存储，如果未使用HTTPS的CDN，即使主站配置了HTTPS，浏览器一样不会标识网站为安全网站，如图：</p><p><img src="https://static.dev-heaven.com/images/https_demo_wrong_firefox.png" alt="firefox"><br><img src="https://static.dev-heaven.com/images/https_demo_wrong_chrome.png" alt="chrom"></p><p>提示很明显，是因为HTTPS网站中混入了http链接，所以下面对七牛CDN升级为HTTPS。</p><h4 id="升级步骤"><a href="#升级步骤" class="headerlink" title="升级步骤"></a>升级步骤</h4><ol><li>在云控制台新建加速域名<br><img src="https://static.dev-heaven.com/images/qiniu_cdn_new.png" alt></li><li>填入你要加速的域名<br><img src="https://static.dev-heaven.com/images/qiniu_cdn_set1.png" alt></li><li>点击如图所示的证书管理，进入证书申请页面<br><img src="https://static.dev-heaven.com/images/qiniu_cdn_cer.png" alt></li><li>点击申请证书<br><img src="https://static.dev-heaven.com/images/qiniu_cdn_apply_cer.png" alt></li><li>填写证书申请的信息<br><img src="https://static.dev-heaven.com/images/qiniu_cdn_msg.png" alt></li><li>申请结果<br>在域名解析中创建CNAME，分别将key value填入<br><img src="https://static.dev-heaven.com/images/cer_apply_result.png" alt></li><li>设置加速域名<br>如果不想麻烦，可以使用默认的HTTPS域名，这样可以省略前面6步<br><img src="https://static.dev-heaven.com/images/new_https_set.png" alt></li><li>等待HTTPS设置生效<br><img src="https://static.dev-heaven.com/images/https_setting_result.png" alt></li><li>在存储空间中设置默认的外链host为HTTPS<br><img src="https://static.dev-heaven.com/images/set_https.png" alt></li></ol><p>至此，HTTPS升级全部完成！</p></div><p class="readmore"><a href="/posts/54876.html">Leer más</a></p></div><div class="post"><h1 class="post-title"><a href="/posts/15154.html">Nginx 如何配置www和non-www域名？</a></h1><div class="post-meta">2016-12-28</div><div class="post-content"><p><img src="https://static.dev-heaven.com/images/nginx.jpg" alt="Nginx" title="Nginx" style="width:100%"><br></p></div><p class="readmore"><a href="/posts/15154.html">Leer más</a></p></div><div class="post"><h1 class="post-title"><a href="/posts/33179.html">【转】fork的项目如何同别人的项目保持同步更新</a></h1><div class="post-meta">2016-12-27</div><div class="post-content"><blockquote><p>问题描述： 当我们 在github上fork出一个项目后，如果原有的项目更新了，怎样保持我们fork出来的项目和原有项目保持同步呢并提交我们的代码更新呢？即怎样保持fork出的项目和上游项目保持更新，怎样创建pull request？关键步骤是使用git 的 rebase 命令。<br></p></blockquote></div><p class="readmore"><a href="/posts/33179.html">Leer más</a></p></div><nav class="page-navigator"><a class="extend prev" rel="prev" href="/page/3/">Anterior</a><a class="page-number" href="/">1</a><a class="page-number" href="/page/2/">2</a><a class="page-number" href="/page/3/">3</a><span class="page-number current">4</span><a class="page-number" href="/page/5/">5</a><a class="extend next" rel="next" href="/page/5/">Siguiente</a></nav></div></div><div class="pure-u-1-4 hidden_mid_and_down"><div id="sidebar"><div class="widget"><form class="search-form" action="//www.google.com/search" method="get" accept-charset="utf-8" target="_blank"><input type="text" name="q" maxlength="20" placeholder="Search"><input type="hidden" name="sitesearch" value="https://www.dev-heaven.com"></form></div><div class="widget"><div class="widget-title"><i class="fa fa-folder-o">Categorías</i></div><ul class="category-list"><li class="category-list-item"><a class="category-list-link" href="/categories/博客/">博客</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/生活/">生活</a></li><li class="category-list-item"><a class="category-list-link" href="/categories/随笔/">随笔</a></li></ul></div><div class="widget"><div class="widget-title"><i class="fa fa-star-o">Etiquetas</i></div><div class="tagcloud"><a href="/tags/springMVC/" style="font-size:15px">springMVC</a> <a href="/tags/docker/" style="font-size:15px">docker</a> <a href="/tags/express/" style="font-size:15px">express</a> <a href="/tags/POI/" style="font-size:15px">POI</a> <a href="/tags/Java/" style="font-size:15px">Java</a> <a href="/tags/Linux/" style="font-size:15px">Linux</a> <a href="/tags/firewall/" style="font-size:15px">firewall</a> <a href="/tags/MySQL/" style="font-size:15px">MySQL</a> <a href="/tags/mybatis/" style="font-size:15px">mybatis</a> <a href="/tags/Ngrok/" style="font-size:15px">Ngrok</a> <a href="/tags/微信/" style="font-size:15px">微信</a> <a href="/tags/ECS/" style="font-size:15px">ECS</a> <a href="/tags/RabbitMQ/" style="font-size:15px">RabbitMQ</a> <a href="/tags/Nginx/" style="font-size:15px">Nginx</a> <a href="/tags/域名/" style="font-size:15px">域名</a> <a href="/tags/Nodejs/" style="font-size:15px">Nodejs</a> <a href="/tags/nvm/" style="font-size:15px">nvm</a> <a href="/tags/SpringBoot/" style="font-size:15px">SpringBoot</a> <a href="/tags/log4j2/" style="font-size:15px">log4j2</a> <a href="/tags/Docker/" style="font-size:15px">Docker</a> <a href="/tags/x-www-form-urlencoded/" style="font-size:15px">x-www-form-urlencoded</a> <a href="/tags/form-data/" style="font-size:15px">form-data</a> <a href="/tags/axios/" style="font-size:15px">axios</a> <a href="/tags/css/" style="font-size:15px">css</a> <a href="/tags/git/" style="font-size:15px">git</a> <a href="/tags/life/" style="font-size:15px">life</a> <a href="/tags/health/" style="font-size:15px">health</a> <a href="/tags/npm/" style="font-size:15px">npm</a> <a href="/tags/nodejs/" style="font-size:15px">nodejs</a> <a href="/tags/nrm/" style="font-size:15px">nrm</a> <a href="/tags/redis/" style="font-size:15px">redis</a> <a href="/tags/Spring/" style="font-size:15px">Spring</a> <a href="/tags/spring-data-redis/" style="font-size:15px">spring-data-redis</a> <a href="/tags/pyenv/" style="font-size:15px">pyenv</a> <a href="/tags/Python/" style="font-size:15px">Python</a> <a href="/tags/ReentrantLock/" style="font-size:15px">ReentrantLock</a> <a href="/tags/https/" style="font-size:15px">https</a> <a href="/tags/poet/" style="font-size:15px">poet</a> <a href="/tags/shell/" style="font-size:15px">shell</a></div></div><div class="widget"><div class="widget-title"><i class="fa fa-file-o">Recientes</i></div><ul class="post-list"><li class="post-list-item"><a class="post-list-link" href="/posts/48761.html">关于ReentrantLock实现的一点思考</a></li><li class="post-list-item"><a class="post-list-link" href="/posts/61735.html">Java内存优化之POI Excel（三）</a></li><li class="post-list-item"><a class="post-list-link" href="/posts/64862.html">Java内存优化之POI Excel（二）</a></li><li class="post-list-item"><a class="post-list-link" href="/posts/27940.html">Java内存优化之POI Excel（一）</a></li><li class="post-list-item"><a class="post-list-link" href="/posts/955.html">最佳实践之Java基础</a></li><li class="post-list-item"><a class="post-list-link" href="/posts/49259.html">Vue + SpringBoot 小问题记录</a></li><li class="post-list-item"><a class="post-list-link" href="/posts/43546.html">git 删除远程分支</a></li><li class="post-list-item"><a class="post-list-link" href="/posts/37317.html">Java规范笔记---读《阿里巴巴Java开发手册》</a></li><li class="post-list-item"><a class="post-list-link" href="/posts/56838.html">Java获取泛型的真实类型</a></li><li class="post-list-item"><a class="post-list-link" href="/posts/6407.html">RabbitMQ从入门到精通—publish confirm机制</a></li></ul></div><div class="widget"><div class="widget-title"><i class="fa fa-external-link">Blogroll</i></div><ul></ul><a href="http://www.example1.com/" title="site-name1" target="_blank">site-name1</a><ul></ul><a href="http://www.example2.com/" title="site-name2" target="_blank">site-name2</a><ul></ul><a href="http://www.example3.com/" title="site-name3" target="_blank">site-name3</a></div></div></div><div class="pure-u-1 pure-u-md-3-4"><div id="footer">Copyright © 2019 <a href="/." rel="nofollow">菜鸟IT路.</a> Powered by<a rel="nofollow" target="_blank" href="https://hexo.io"> Hexo.</a><a rel="nofollow" target="_blank" href="https://github.com/tufu9441/maupassant-hexo"> Theme</a> by<a rel="nofollow" target="_blank" href="https://github.com/pagecho"> Cho.</a></div></div></div><a class="show" id="rocket" href="#top"></a><script type="text/javascript" src="/js/totop.js?v=0.0.0" async></script><script type="text/javascript" src="//lib.baomitu.com/fancybox/3.5.7/jquery.fancybox.min.js" async></script><script type="text/javascript" src="/js/fancybox.js?v=0.0.0" async></script><link rel="stylesheet" type="text/css" href="//lib.baomitu.com/fancybox/3.5.7/jquery.fancybox.min.css"><script type="text/javascript" src="/js/codeblock-resizer.js?v=0.0.0"></script><script type="text/javascript" src="/js/smartresize.js?v=0.0.0"></script></div></body></html>